def flatten(nested):
    try:
        # 不迭代类似于字符串的对象:
        try:
            nested + ''
        except TypeError:
            pass
        else:
            raise TypeError

        for sublist in nested:
            for element in flatten(sublist):
                yield element
    except TypeError:
        yield nested


l_nested = [[1, 2], [3, 4], [5], 'abcde']
# l_nested = [[1, 2], [3, 4], [5]]
print(list(flatten(l_nested)))
